{extend name="platform/base" /} {block name="main"}
<section class="panel panel-default">
	<div class="table-responsive">
		<table class="table table-striped b-t b-light text-sm">
			<thead>
				<tr>
					<th width="10"><input type="checkbox"></th>
					<th class="center">编号</th>
					<th class="center">招商员信息</th>
					<th class="center">会员信息</th>
					<th class="center">招商员等级</th>
					<th class="center">上级招商员</th>
					<th class="center">状态</th>
					<th class="center">支付类型</th>
					<th class="center">创建时间</th>
					<th class="center">操作</th>
				</tr>
			</thead>
			<tbody id="list">
				<tr></tr>
			</tbody>
		</table>
	</div>
	{include file="platform/page" /}
</section>

{/block} {block name="script"}
<script type="text/javascript">
$(function(){
	LoadingInfo(1);
});
//查询用户列表
function LoadingInfo(pageIndex) {
	var search_text = $("#search_text").val();
	$.ajax({
		type : "post",
		url : "PLATFORM_MAIN/Assistant/businessAssistantList",
		async : true,
		data : {
			"pageIndex" : pageIndex, "search_text" : search_text
		},
		success : function(data) {
// 			document.write(JSON.stringify(data));
// 			alert(JSON.stringify(data));
			var html = '';
			$("#total_count_num").text(data["total_count"]);
			$("#page_count_num").text(data["page_count"]);
			$("#page_count").val(data["page_count"]);
			$("#pageNumber a").remove();
			
			for (var i = 0; i < data["data"].length; i++) {
				
				var item_data = data["data"][i];
				if(item_data["status"] == 1){
					$status_name = '正常';
				}else if(item_data["status"] == -1){
					$status_name = '锁定';
				}
				
				if(item_data["parent_assistant_id"]==0){
					$parent_assistant_name="--";
				}else{
					$parent_assistant_name = item_data['parent_assistant_name'];
				}
				
				if(item_data["pay_method"]==1){
					$pay_method_name="微信支付";
				}else if(item_data["pay_method"]==1){
					$pay_method_name="支付宝支付";
				}else{
					$pay_method_name="线下支付";
				}
				
				html += '<tr>';
				html += '<td><input type="checkbox" name="sub" value="'+ data['data'][i]['uid']+'"></td>';
				html += '<td class="center">' + item_data["assistant_id"] + '</td>';
				html += '<td class="center">' + item_data["real_name"] + '<br/>'+item_data["mobile"]+'</td>';
				
				<!-- 头像：昵称、 -->
				var img = '<img src="PLATFORM_IMG/avatar_default.jpg" style="border-radius: 50%;"/>';
				if(item_data['user_info']['user_headimg']!=null && item_data['user_info']['user_headimg'] != ''){
					img = '<div style="width:70px;margin:0 auto;height:50px;"><img src="__UPLOAD__/' +item_data['user_info']['user_headimg']+'"  style="height:100%;max-width:100%;"/></div>';
				}
				html += '<td class="center">'+ img + item_data['user_info']['nick_name'] + "</td>";
				
				html += '<td class="center">' + item_data["level_info"]["level_name"] + '</td>';
				html += '<td class="center">' + $parent_assistant_name + '</td>';
				html += '<td class="center">' + $status_name + '</td>';
				html += '<td class="center">' + $pay_method_name + '</td>';
				html += '<td class="center">' + item_data["create_time"] + '</td>';
				html += '<td class="center">';
				if(data['data'][i]['statu'] == 1){
					html += '<a href="javascript:void(0);" onclick="agree('+item_data["assistant_id"]+', -1)">锁定</a>';
				}else if(data['data'][i]['audit'] == -1){
					html += '<a href="javascript:void(0);" onclick="agree('+item_data["assistant_id"]+', 1)">解锁</a>';
				}
				html += '</td>';
				html += '</tr>';
			}
			
			if (data["data"].length == 0) {
				html += '<tr><th colspan="10">暂无符合条件的数据记录</th></tr>';
			}
			$("#list").html(html);
				var totalpage = $("#page_count").val();
		if (totalpage == 1) {
			changeClass("all");
		}
		var $html = pagenumShow(jumpNumber,totalpage,{$pageshow})
		$("#pageNumber").append($html);
		}
	});
}	
	
function agree(assistant_id,audit){
	$.ajax({
		type : "post",
		url : "PLATFORM_MAIN/Assistant/BusinessAssistantAudit",
		async : true,
		data : {
			"assistant_id" : assistant_id,
			"audit" : audit
		},
		success : function(data) {
			if(data["code"] > 0 ){
				showMessage('success', data["message"],'PLATFORM_MAIN/Assistant/businessAssistantList');
			}else{
				showMessage('error', data["message"]);
			}
		}
	});
}

$("#search_text").keypress(function(e){
	if(e.keyCode == 13){
		LoadingInfo(1);
	}
});
</script>
{/block}